import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class AvlTreeTest {
    public static void main(String[] args) {
        AvlTress<Integer> tree = new AvlTress<>();
        /**
         *           12
         *      8          14
         *         9          15
         *            10
         */
        tree.insert(12);
        tree.insert(8);
        tree.insert(14);

        tree.insert(15);
        tree.insert(9);
        tree.insert(10);

        List<List<AvlTress<Integer>.Node<Integer>>> levels = tree.orderLevel();
        levels.forEach(list->{
            list.forEach(node-> System.out.print(node.val+"\t"));
            System.out.println();
        });
        System.out.println("-----------search--------------------");
        AtomicInteger searchDeep = new AtomicInteger(0);
        tree.search(5, searchDeep);
        System.out.println("搜索5比较次数为："+searchDeep.get());
    }
}
